package com.idis.dbApp.mapper;

import com.idis.entity.Contact;
import org.apache.ibatis.jdbc.SQL;

public class ContactSqlProvider {

    public String insertSelective(Contact record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("contact");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getContact1() != null) {
            sql.VALUES("contact_1", "#{contact1,jdbcType=VARCHAR}");
        }
        
        if (record.getContact2() != null) {
            sql.VALUES("contact_2", "#{contact2,jdbcType=VARCHAR}");
        }
        
        if (record.getContact3() != null) {
            sql.VALUES("contact_3", "#{contact3,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            sql.VALUES("picture", "#{picture,jdbcType=VARCHAR}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(Contact record) {
        SQL sql = new SQL();
        sql.UPDATE("contact");
        
        if (record.getContact1() != null) {
            sql.SET("contact_1 = #{contact1,jdbcType=VARCHAR}");
        }
        
        if (record.getContact2() != null) {
            sql.SET("contact_2 = #{contact2,jdbcType=VARCHAR}");
        }
        
        if (record.getContact3() != null) {
            sql.SET("contact_3 = #{contact3,jdbcType=VARCHAR}");
        }
        
        if (record.getPicture() != null) {
            sql.SET("picture = #{picture,jdbcType=VARCHAR}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}